# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=z3
pkgver=4.8.8
pkgrel=0
pkgdesc="Theorem prover from Microsoft Research"
url="https://github.com/Z3Prover/z3"
arch="all !s390x !aarch64 !mips !mips64"
license="MIT"
makedepends="cmake python3"
subpackages="$pkgname-dev py3-$pkgname:py3:noarch"
source="https://github.com/Z3Prover/z3/archive/z3-$pkgver.tar.gz
	none-build-type.patch"
builddir="$srcdir/z3-z3-$pkgver"

build() {
	mkdir build && cd build
	cmake -G "Unix Makefiles" \
		-DZ3_BUILD_PYTHON_BINDINGS=True \
		-DZ3_INSTALL_PYTHON_BINDINGS=True \
		-DPYTHON_EXECUTABLE=/usr/bin/python3 \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		..
	make

	# Binary for running the unit tests
	make test-z3
}

check() {
	./build/test-z3 -a
}

package() {
	cd "$builddir/build"
	make DESTDIR="$pkgdir" install
}

py3() {
	pkgdesc="Python bindings for $pkgname"
	depends="python3"

	mkdir -p "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/lib/python3* \
		"$subpkgdir"/usr/lib/
}

sha512sums="a6823cadb7cdad11b8f0db1530676c0ec4853886dfb3c4dbc5b798c5dbd445afb0c61675f81cb7f99c1b1734d9cd0ec96a07c68a948da3c25801fc6767fea47f  z3-4.8.8.tar.gz
9a99777d29558ffcc15fa43e3dc1da46261469c60561c5bc3bcaab40164ed59c45386ed597f27c8160e69acf16d0d8f3ddb06a53b52886ab146d54becc9ccb02  none-build-type.patch"
